#ifndef _TASK_MODEL_H_
#define _TASK_MODEL_H_

#include <stdio.h>


///////////////////////////////////////////////////////////
#define TASK_V void
typedef int             TASK_INT;
typedef unsigned int    TASK_UINT;


///////////////////////////////////////////////////////////
#define TASKAPI(function) task_private##function

///////////////////////////////////////////////////////////
#define SYS_TASK_SUM        1
#define USER_TASK_SUM       2
#define TASK_SUM            SYS_TASK_SUM+USER_TASK_SUM

///////////////////////////////////////////////////////////
typedef enum
{
    SSTATE_NULL = 0,
    SSTATE_INITED,
    SSTATE_RUNNING,
    SSTATE_STOP,
}TASKSTATE;

typedef enum{

    TASK_STEM_INIT = 0,
    TASK_STEM_RUN,
    TASK_STEM_WAIT,
    TASK_STEM_DEL,
}TASK_STEM_CMD;

struct TaskMsg{

    char task_name[64];
    TASK_STEM_CMD cmd;
};

struct TaskModel_t{
	
	char name[64];
	TASKSTATE (*TaskInit)(struct TaskModel_t *vtask);
	TASKSTATE(*TaskRun)(struct TaskModel_t *vtask);
    TASKSTATE(*TaskWait)(struct TaskModel_t *vtask);
	TASKSTATE state;
    TASK_UINT Task_Delay;
};

extern TASK_UINT TASK_GET_Heartbeat(TASK_V);
extern struct TaskModel_t **TASK_GET_LIST(TASK_V);
extern TASK_V TASK_SET_DELAY(struct TaskModel_t *vtask, TASK_UINT delay);
extern TASK_V TASK_ALL_INIT(struct TaskModel_t *gTask[]);
extern TASK_V TASK_RUN_MACHINE(struct TaskModel_t *gTask[]);



#endif //_SESSION_H_